import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		forcedLogin: 1, // 强制登录 是1  否0 
		hasLogin: false,
		checkOrder: '', // 选中的订单,临时数据
		userInfo: {
			// UserId:'172665f5-8dfd-4588-a828-fbdd025e989a',
			// Account:'admin',
			UserId: '',
			Account: '',
			CompanyId: "",
			BaseURL: '' ,
			authModel:''
		},
		UserInfo: {},
		baseUrl: "",
		authModel: "", // 账户权限
		checkOrder: '', // 选中的订单,临时数据
		taxRate: [], // 税率
		materUse: [], // 用途
		wareType:[] , // 入库类型
		checkData: [], // 选中的物料书架
		approval: {} , // 审批的数据
	},
	mutations: {
		// 登录成功后保存数据到store
		longinSuccessReduce(state, provider) {
			// console.log(JSON.stringify(provider));
			state.userInfo = provider.userInfo;
			state.baseUrl = provider.baseUrl;
			state.authModel = provider.authModel;
		},
		
		setUserInfo(state, provider) {
			state.UserInfo = provider;
		},

		setCheckData(state, data) {
			state.checkData = [] 
			state.checkData = [...data];
		},

		PushCheckData(state, data) {
			// console.log("0", data);
			// console.log("1", state.checkData);
			state.checkData.push(data);
			// console.log("2", state.checkData);
		},

		deleteCheckData(state, data) {
			state.checkData.splice(data, 1)
		},

		setCheckOrder(state, data) {
			state.checkOrder = data;
		},
		// 设置税率
		setTaxRate(state, data) {
			state.taxRate = data.taxRate
			state.materUse = data.materUse
			state.wareType = data.wareType
			state.outType = data.outType
		},
		// 设置待审批，已审批，已驳回的数据
		setApprovalNum(state, data){
			state.approval = {...data}
		}

	},
	actions: {

	},
	modules: {

	}
})

export default store